<?php
require_once 'init.php';
if(!$sessionID){
	header('location:login.php');
}
$id = isset($_POST['id'])?$_POST['id']:0;
$src = isset($_POST['src'])?$_POST['src']:'';
$action = isset($_POST['action'])?$_POST['action']:'';
$name = isset($_POST['name'])?$_POST['name']:'';
if($id==0||!in_array($action,array('wedding','studio','cooperation','guest'))){
	header('location:index.php');
}elseif($action=='wedding'){
	$page = 'page3';
}elseif($action=='studio'){
	$page = 'page4';
}elseif($action=='cooperation'){
	$page = 'page6';
}elseif($action=='guest'){
	$page = 'page7';
}
$dom = new DOMDocument('1.0','UTF-8');
$dom->load($contentDB);
$pages = $dom->getElementsByTagName($page);
$photo = $pages->item(0);
$items = $photo->getElementsByTagName('photo');
foreach($items as $item){
	$imgId = $item->getAttribute('id');
	if((int)$imgId == (int)$id){
		$item->setAttribute('coverUrl',$src);
		$item->setAttribute('photoName',$name);
	}
}
$dom->save($contentDB);
XmlTool::ADDUTF8BOM($contentDB);
header('location:album.php?action='.$aciton);
?>
